<?php

use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;

class DropCreatePricesTable extends Migration
{

    /**
     * Run the migrations.
     *
     * @return void
     */
    public function up()
    {
        Schema::dropIfExists('prices');
        Schema::create('prices', function (Blueprint $table) {
            $table->increments('id');
            $table->string('name', 100)->index();
            $table->string('title', 100)->nullable();
            $table->string('subtitle', 100)->nullable();
            $table->string('short_desc', 100);
            $table->decimal('prices', 20, 2);
            $table->integer('pmtag_id')->unsigned()->nullable();
            $table->integer('metering_period_id')->unsigned()->nullable();
            $table->timestamp('startdate')->nullable();
            $table->timestamp('enddate')->nullable();
            $table->timestamps();
            $table->softDeletes();
            $table->foreign('pmtag_id')->references('id')->on('pmtags')->onUpdate('cascade')->onDelete('cascade');
            $table->foreign('metering_period_id')->references('id')->on('metering_periods')->onUpdate('cascade')->onDelete('cascade');
        });
    }

    /**
     * Reverse the migrations.
     *
     * @return void
     */
    public function down()
    {
        Schema::dropIfExists('prices');
    }
}
